// pages/home/home.js
Page({
  data: {
    swiperList: [],
    gridList: []
  },
  onLoad() {
    // 获取轮播图数据
    this.getSwiperList()
    // 获取九宫格数据
    this.getGridList()
  },
  getSwiperList() {
    wx.request({
      url: 'https://applet-base-api-t.itheima.net/slides',
      method: 'GET',
      // 注意这儿要是箭头函数，否则内部的 this 指向会有问题
      success: (res) => {
        this.setData({
          swiperList: res.data,
        })
      },
    })
  },
  getGridList() {
    wx.request({
      url: 'https://applet-base-api-t.itheima.net/categories',
      method: 'GET',
      success: (res) => {
        this.setData({
          gridList: res.data,
        })
      },
    })
  },
})